package com.secondkill.service;

import com.secondkill.entity.MiaoshaUser;
import com.secondkill.entity.OrderInfo;
import com.secondkill.vo.GoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by IBM on 2018/7/11.
 */
@Service
public class MiaoshaService {

    @Autowired
    MiaoshaGoodsService goodsService;

    @Autowired
    OrderService orderService;
    public OrderInfo miaosha(MiaoshaUser user, GoodsVo goods) {

        // 1减少库存
        goodsService.reduceStock(goods);
        // 2 下订单（写订单表和秒杀订单表）
        return orderService.createOrder(user, goods);

    }
}
